package com.tempjob.common.message;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

/**
 * @author hui
 * @Date 2023/9/21 21:48
 **/
@Service
public class MessagePublisher {


    @Autowired
    private RedisTemplate redisTemplate;

    @Value("${workform.queue:workform:sendDown:queue:sendQueue}")
    private String redisQueue;

    @Value("${workform.queue:workform:send:queue:userWorkQueue}")
    private String redisUserWorkQueue;

    /**
     * 发送消息
     *
     * @param channel
     * @param message
     */
    private void publish(String channel, String message) {
        redisTemplate.convertAndSend(channel, message);
    }

    public void publishSendMessage(Long wfContentId) {
        this.publish(redisQueue, wfContentId.toString());
    }

    public void publishSendTaskMessage(Long sendBackId) {
        this.publish(redisUserWorkQueue, sendBackId.toString());
    }


}
